<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- 使用taglib指令导入jstl标记 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ page import="java.util.*" %>     
<%@ page import="com.niit.booksystem.BookEntity" %>    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>书籍列表</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body>
<%
 //从request中获取数据，并放到当前jsp页面
 // List<BookEntity> data = (List<BookEntity>)request.getAttribute("lstBooks");
//从session中获取数据，并放到当前jsp页面
List<BookEntity> data = (List<BookEntity>)session.getAttribute("lstBooks");
 pageContext.setAttribute("data",data);

%>

<div class="container">
	<h1>书籍列表信息：</h1>
	<table class="table table-bordered text-center table-hover table-striped">
		<tr class="table-primary">
			<th>ID</th>
			<th>编号</th>
			<th>名称</th>
			<th>作者</th>
			<th>单价</th>
		</tr>
		<!-- 使用forEach 循环数据-->
		<c:forEach items="${data}" var="book">
			<tr>
				<td>${book.id}</td>
				<td>${book.code}</td>
				<td>${book.name}</td>
				<td>${book.author}</td>
				<td>${book.unitPrice}</td>
			</tr>
		</c:forEach>
	</table>
</div>


</body>
</html>